
import Vue from 'vue'
// By default we import all the components.
// Only reserve the components on demand and remove the rest.
// Style is always required.
import router from './common/config/router'
import cube from 'cube-ui'
import App from './App'
import Storage from 'vue-web-storage'
import layoutContent from './components/layout/layoutContent'
import VueAwesomeSwiper from 'vue-awesome-swiper'
import store from './store/Store'
import VueAMap from 'vue-amap'
import headerbar from '@/components/layout/headerbar.vue'
import noData from '@/components/common/noData.vue'
import fetchData from '@/components/common/fetchData.vue'
import abnormal from '@/components/common/abnormal.vue'
import drag from '@/components/common/drag.vue'
import onBottom from '@/components/common/onBottom.vue'
import bannerImgComponent from '@/components/common/bannerImgComponent.vue'
import readScoreComponent from '@/components/common/readScoreComponent.vue'
// import VueLazyload from 'vue-lazyload'

// require styles
import 'animate.css'
import '@/common/stylus/fontAwesome/all.min.css'
import '../static/css/mui.css'
import '../static/css/build.css'
import '@/common/stylus/moon.scss'
import '@/common/stylus/dangjian.scss'
import cpsPlugins from '@/common/config/components'
import fetchService from '@/service/loginService'
import tools from '@/utils/tools'
import '@/common/dialog/index'
import directive from '@/common/directive/index'
import cache from '@/common/cache/cache'
import version from '@/common/version'
import {logEvent} from '@/utils/Log'

Vue.use(Storage, {
  prefix: 'kiosk_', // default `app_`
  drivers: ['session', 'local'] // default 'local'
})
Vue.use(cpsPlugins)
Vue.use(VueAwesomeSwiper, /* { default global options } */)
Vue.component('layout-content', layoutContent)
Vue.component('headerbar', headerbar)
Vue.component('noData', noData)
Vue.component('fetchData', fetchData)
Vue.component('abnormal', abnormal)
Vue.component('onBottom', onBottom)
Vue.component('dragComp', drag)
Vue.component('bannerImg', bannerImgComponent)
Vue.component('readScore', readScoreComponent)

Vue.prototype.fetchService = fetchService
Vue.prototype.tools = tools
Vue.prototype.cache = cache
Vue.prototype.logEvent = logEvent

// createAPI(Vue, SubscribeDialog, [], true)
Vue.use(directive)
Vue.use(cube)
Vue.config.productionTip = false
// Vue.use(VueLazyload, {
//   // loading: require('../static/images/dangjian/home/water-logo.png'), // 加载中图片，一定要有，不然会一直重复加载占位图
//   error: require('../static/images/dangjian/home/img-load-error.jpg'),  // 加载失败图片
//   attempt: 1
// })

// 附件上传阿里
Vue.prototype.TYPE = 'ALI'

// 引入vue-amap
Vue.use(VueAMap)
// 初始化vue-amap
VueAMap.initAMapApiLoader({
  // 高德的key
  key: '1790259a6ecff843ef0ae01192e822fe',
  // 插件集合
  plugin: ['AMap.Autocomplete', 'AMap.PlaceSearch', 'AMap.Scale', 'AMap.OverView', 'AMap.ToolBar', 'AMap.MapType', 'AMap.PolyEditor', 'AMap.CircleEditor', 'AMap.Geocoder', 'AMap.Geolocation'],
  // 高德 sdk 版本，默认为 1.4.4
  v: '1.4.15'
})
window.getVersion = () => {
  return version.version
}

/* eslint-disable no-new */
window.myvue = new Vue({
  router,
  store,
  el: '#app',
  render: h => h(App)
})

window.onerror = function (err) {
  logEvent(0, {content_type: 0, content_title: err})
}
